package com.ruoyi.system.domain.function;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.system.domain.ERP.ProdPlanErpDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import com.ruoyi.common.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;

/**
 * 生产计划对象 prod_plan
 *
 * @author ruoyi
 * @date 2023-02-13
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
@TableName("prod_plan")
public class ProdPlan implements Serializable {

    private static final long serialVersionUID=1L;


    /** 生产计划组件id */
    @TableId(value = "plan_id")
    private Long planId;

    /** 华为任务令 */
    @Excel(name = "华为任务令")
    @ApiModelProperty(value = "华为任务令")
    private String taskTon;

    /** 交货日期 */
    @Excel(name = "交货日期" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "交货日期 yyyy-MM-dd HH:mm:ss")
    private Date deliveryTime;

    /** 产品编码 */
    @ApiModelProperty(value = "产品编码")
    @Excel(name = "产品编码")
    private String productCode;

    /** 产品名称 */
    @ApiModelProperty(value = "产品名称")
    @Excel(name = "产品名称")
    private String productName;


    /** 计划编码 */
    @Excel(name = "计划编码")
    @ApiModelProperty(value = "计划编码")
    private String planCode;

    /** 物料编码 */
    @ApiModelProperty(value = "物料编码")
    private String materialCode;

    /** 物料名称 */
    @Excel(name = "物料名称")
    @ApiModelProperty(value = "物料名称")
    private String materialName;

    /** 产线编码 */
    @ApiModelProperty(value = "产线编码")
    private String lineCode;

    /** 产线名称 */
    @Excel(name = "产线名称")
    @ApiModelProperty(value = "产线名称")
    private String lineName;

    /** 工艺路线编码 */
    @ApiModelProperty(value = "工艺路线编码")
    private String routingCode;

    /** 工艺路线名称 */
    @Excel(name = "工艺路线名称")
    @ApiModelProperty(value = "工艺路线名称")
    private String routingName;

    /** 客户编码 */
    @ApiModelProperty(value = "客户编码")
    private String customerCode;

    /** 客户名称 */
    @Excel(name = "客户名称")
    @ApiModelProperty(value = "客户名称")
    private String customerName;

    /** 客户订单号 */
    @Excel(name = "客户订单号")
    @ApiModelProperty(value = "客户订单号")
    private String customerOrderNum;

    /** 计划开始时间 */
    @Excel(name = "计划开始时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "计划开始时间 yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    /** 计划结束时间 */
    @Excel(name = "计划结束时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "计划结束时间 yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    /** 计划数量 */
    @Excel(name = "计划数量")
    @ApiModelProperty(value = "计划数量")
    private Double planNumber;

    /** 已下发数量 */
    @Excel(name = "已下发数量")
    @ApiModelProperty(value = "已下发数量")
    private Double comNumber;

    /** 剩余可下发量 */
    @Excel(name = "剩余可下发量")
    @ApiModelProperty(value = "剩余可下发量")
    private Double surplusNumber;

    /** 计划状态 */
    @Excel(name = "计划状态")
    @ApiModelProperty(value = "计划状态0新建1已拆分2已关闭3弃审")
    private Integer planState;

    /** 完工状态 */
    @Excel(name = "完工状态")
    @ApiModelProperty(value = "完工状态 0未完工1已完工")
    private Integer comState;

    /** 备注 */
    @Excel(name = "备注")
    @ApiModelProperty(value = "备注")
    private String remarks;

    @ApiModelProperty(value = "类型")
    private String type;

    @ApiModelProperty(value = "生产订单每行主键id 订单号加行号")
    private String scddErpId;

    @ApiModelProperty(value = "定时比对客户条码回传生产是否合格 0不合格1合格")
    private Integer ifSnTask;
    @ApiModelProperty(value = "定时比对产品条码属性回传生产是否合格 0不合格1合格")
    private Integer ifAttributeTask;
    @ApiModelProperty(value = "定时比对bom子件生产是否合格 0不合格1合格")
    private Integer ifBomTask;

    @ApiModelProperty(value = "生产订单单号的ID")
    private String mainOrderId;

    @ApiModelProperty(value = "部门名称")
    private String deptName;

    @ApiModelProperty(value = "部门编码")
    private String deptCode;

    /** 创建者 */
    private String createBy;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 更新者 */
    private String updateBy;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @ApiModelProperty(value = "物料规格")
    private String materialNorms;
    @ApiModelProperty(value = "物料计量单位")
    private String unit;

    @ApiModelProperty(value = "传输时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date transferDate;

//    @ApiModelProperty(value = "产品硬件版本")
//    private String hardwareVersion;
//
//    @ApiModelProperty(value = "产品软件版本")
//    private String softwareVersion;

    private Integer status;

    private Date documentDate;

    private String productionVersion;

    private String factory;

    private String sapId;

    @Column(columnDefinition = "json")
    private String sapJson;

    public ProdPlan(ProdPlanErpDTO dto){
        this.planCode = dto.getOrderNumber();
        this.taskTon = dto.getTaskTon();
        this.mainOrderId = dto.getMainOrderId();
        this.deptCode = dto.getDeptCode();
        this.deptName = dto.getDeptName();
//        this.scddErpId = dto.getOrderId();
        this.type = dto.getType();
        this.materialCode = dto.getMaterialCode();
        this.materialName = dto.getMaterialName();
        this.materialNorms = dto.getMaterialNorms();
        this.unit = dto.getUnit();
        this.startTime = dto.getStartTime();
        this.endTime = dto.getEndTime();
        this.planNumber = dto.getOrderNum();
        this.createBy = dto.getCreatedBy();
        this.createTime = dto.getCreatedDate();
        this.updateBy = dto.getLastUpdatedBy();
        this.updateTime = dto.getLastUpdatedDate();
        this.transferDate = dto.getTransferDate();
        this.productCode = dto.getMaterialCode();
        this.productName = dto.getMaterialName();
        this.remarks = dto.getRemarks();
        this.status = dto.getStatus();
        this.documentDate = dto.getDocumentDate();
        this.productionVersion = dto.getProductionVersion();
        this.factory = dto.getFactory();
        this.sapId = dto.getSapId();
        this.sapJson = JSON.toJSONString(dto);
    }

}
